Getting Started
npm install @techor/one-liner
import oneLiner from '@techor/one-liner';
import { l } from '@techor/one-liner';
l
is equal to l
Strings
l`a ${true && 'b'} c`;
Objects
l`a ${{ b: true, c: false, d: isTrue() }} e`;
Arrays
l`a ${['b', 0, false, 'c']} d`;
Resolve types
l`a ${true} ${false} ${''} ${null} ${undefined} ${0} ${NaN} b`
Trim and clear
- Remove newlines
- Convert consecutive spaces to one space
l`
a
b
${undefined}
c d
`
Mixed and nested
l`
a
${
[
1 && 'b',
{ c: false, d: null },
['e', ['f']]
]
}
g h
`;
Execute like a function
l`a b ${['c', 'd']} ${{ e: true, f: false }} ${true && 'g'}`;
line('a b', ['c', 'd'], { e: true, f: false }, true && 'g');
Related
Inspiration
- clsx - A tiny utility for constructing
className
strings conditionally